import request from '@/utils/request';
import {AxiosPromise} from 'axios';
import {BusinessVO, BusinessForm, BusinessQuery} from '@/api/business/config/types';

/**
 * 查询业务参数配置列表
 * @param query
 * @returns {*}
 */

export const listBusiness = (query?: BusinessQuery): AxiosPromise<BusinessVO[]> => {
  return request({
    url: '/business/business/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询业务参数配置详细
 * @param businessConfigId
 */
export const getBusiness = (businessConfigId: string | number): AxiosPromise<BusinessVO> => {
  return request({
    url: '/business/business/' + businessConfigId,
    method: 'get'
  });
};

/**
 * 新增业务参数配置
 * @param data
 */
export const addBusiness = (data: BusinessForm) => {
  return request({
    url: '/business/business',
    method: 'post',
    data: data
  });
};

/**
 * 修改业务参数配置
 * @param data
 */
export const updateBusiness = (data: BusinessForm) => {
  return request({
    url: '/business/business',
    method: 'put',
    data: data
  });
};

/**
 * 删除业务参数配置
 * @param businessConfigId
 */
export const delBusiness = (businessConfigId: string | number | Array<string | number>) => {
  return request({
    url: '/business/business/' + businessConfigId,
    method: 'delete'
  });
};
/**
 * 修改状态
 * @param data
 */
export const updateStatus = (businessConfigId: string | number) => {
  return request({
    url: '/business/business/updateStatus',
    method: 'put',
    params: {businessConfigId}
  });
};
/**
 * 查询业务参数配置列表
 * @param query
 * @returns {*}
 */
export const getByKeyApi = (configKey?: string): AxiosPromise<BusinessVO[]> => {
  return request({
    url: '/business/business/getByKey',
    method: 'get',
    params: {configKey}
  });
};
